﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using XYAC.Framework.MonitorTireMaterialManual.Entities;
using XYAC.Framework.MonitorTireMaterialManual.Extensions;
using XYAC.Framework.MonitorTireMaterialManual.IServices;
using XYAC.Framework.MonitorTireMaterialManual.LocalData.Context;
using XYAC.Framework.MonitorTireMaterialManual.LocalData.Models;
using XYAC.Framework.MonitorTireMaterialManual.OracleRemoteDB;

namespace XYAC.Framework.MonitorTireMaterialManual.Services
{
    internal class YB_PROCESS_STEPService : ServiceBase<int, OracleMesContext>, IYB_PROCESS_STEPService
    {

        private const string __REMOTE_SYNC_STATE_PENDING = "PENDING";
        private const string __REMOTE_SYNC_STATE_COMPLETE = "COMPLETE";
        private const string __REMOTE_SYNC_STATE_PLANED = "PLANED";
        private const string __TABLENAME_SpecVal = "SpecVal";
        private const string __TABLENAME_WeightData = "WeightData";

        public YB_PROCESS_STEPService(IOptionsMonitor<AppConfig> appConfig, ILogger<YB_PROCESS_STEPService> logger, IServiceProvider provider) : base(appConfig, logger, provider)
        {
            //this.MesDb = provider.GetService<OracleMesContext>();
            //this.LocalDb = provider.GetService<LocalDataContext>();
            this.Logger = logger;
        }

        //public OracleMesContext MesDb { get; }
        //public LocalDataContext LocalDb { get; }
        public ILogger Logger { get; }
         



        internal int Add(YB_PROCESS_STEP insertData)
        {
            using (var scope = Provider.CreateScope())
            {
                var MesDb = scope.ServiceProvider.GetService<OracleMesContext>();

                MesDb.Add(insertData);
                return MesDb.SaveChanges();
            }
        }


         


    }
}
